t=int(input())
for _ in range(t):
x,y,n=map(int,input().split())
temp=n%x
while True:
if temp==y:
print(n)
break
else:
if y<temp:
print(n-temp+y)
break
else:
temp+=x
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
ll sum,mx,mn,n,m,k,d,i,j,t,ans,a,b,c,x,y,l,r;
string s,s1,s2;
char ch;
int main(){
ios::sync_with_stdio(0);
cin.tie(0),cout.tie(0);
t=1;cin>>t;
while(t--){
cin>>a>>b>>c;
if(c-c%a+b<=c){
cout<<c-c%a+b<<endl;
}else{
cout<<c-c%a-(a-b)<<endl;
}
}
}
1454A - Special Permutation | 1359A - Berland Poker |
459A - Pashmak and Garden | 1327B - Princesses and Princes |
1450F - The Struggling Contestant | 1399B - Gifts Fixing |
1138A - Sushi for Two | 982C - Cut 'em all |
931A - Friends Meeting | 1594A - Consecutive Sum Riddle |
1466A - Bovine Dilemma | 454A - Little Pony and Crystal Mine |
2A - Winner | 1622B - Berland Music |
1139B - Chocolates | 1371A - Magical Sticks |
1253A - Single Push | 706B - Interesting drink |
1265A - Beautiful String | 214A - System of Equations |
287A - IQ Test | 1108A - Two distinct points |
1064A - Make a triangle | 1245C - Constanze's Machine |
1005A - Tanya and Stairways | 1663F - In Every Generation |
1108B - Divisors of Two Integers | 1175A - From Hero to Zero |
1141A - Game 23 | 1401B - Ternary Sequence |